package com.demo.springBoot2.mapper;

import com.demo.springBoot2.entity.UsersFriend;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demo.springBoot2.entity.dto.MyFriendAndInfoDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 好友关系 Mapper 接口
 * </p>
 *
 * @author wuHua·pl
 * @since 2024-03-16
 */
@Mapper
public interface UsersFriendMapper extends BaseMapper<UsersFriend> {
    @Select("select uf.id,ui.nickname,uf.create_time from users_friend as uf,users_info as ui where uf.friend_id = ui.userId AND uf.status = 0 and uf.friend_id = #{userId}")
    List<MyFriendAndInfoDTO> selectUserFriendsByUserId(Integer userId);
    @Select("select uf.friend_id as id,ui.nickname,uf.create_time from users_friend as uf,users_info as ui where uf.friend_id = ui.userId AND uf.status = 1 and uf.user_id = #{userId}")
    List<MyFriendAndInfoDTO> selectFriendByUserId(Integer userId);
    @Select("select id from users_friend where user_id = #{userId} and friend_id = #{friendId}")
    UsersFriend selectFriend(UsersFriend usersFriend);
}
